﻿namespace JelloPhysics
{
    using Microsoft.Xna.Framework;
    using System;

    public class PointMass
    {
        public Vector2 Force;
        public float Mass;
        public Vector2 Position;
        public Vector2 Velocity;

        public PointMass()
        {
            this.Mass = 0f;
            this.Position = this.Velocity = this.Force = Vector2.Zero;
        }

        public PointMass(float mass, Vector2 pos)
        {
            this.Mass = mass;
            this.Position = pos;
            this.Velocity = this.Force = Vector2.Zero;
        }

        public void integrateForce(float elapsed)
        {
            if (this.Mass != float.PositiveInfinity)
            {
                float num = elapsed / this.Mass;
                this.Velocity.X += this.Force.X * num;
                this.Velocity.Y += this.Force.Y * num;
                this.Position.X += this.Velocity.X * elapsed;
                this.Position.Y += this.Velocity.Y * elapsed;
            }
            this.Force.X = 0f;
            this.Force.Y = 0f;
        }
    }
}

